home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
TECHNICA
/
AUTOCAD
/
H108.ZIP
/
ZERO.ZIP
/
ZERO.LSP
Wrap
Text File
|
1982-03-12
|
12KB
|
305 lines
;* ZERO.LSP IS A PROGRAM TO ZERO THE
;* Z COORDINATES OF ALL ENTITIES IN
;* THE DRAWING.
;*
;* WRITTEN BY P. REBBECHI 12 JULY 1991
;* COPYRIGHT CMPS&F VIC
;*
;* DXF takes an integer dxf code and an entity data list.
;* It returns the data element of the association pair.
;*
(defun dxf(code elist)
(cdr (assoc code elist)) ;finds the association pair, strips 1st element
)
; circ0.LSP
; Change z coord to zero
;
(defun circ0 (/ g n lg e os ns el nl)
(princ "\nChanging CIRCLES: ")
(setq g (ssget "P")) ; get entities
(if g (progn ; check if any
(setq n 0 lg (sslength g)) ; set counter & No of entities
(while (< n lg)
(if (= "CIRCLE" ; check entity type
(cdr (assoc 0 (setq e (entget (ssname g n))))))
(progn ; if OK update
(setq os (assoc 10 e)) ; get current ctr pt
(setq ns (list(car os)(cadr os)(caddr os) 0.0))
(setq e (subst ns os e)) ; swap
(setq el (assoc 38 e)) ; get current elev
(setq nl (cons 38 0.0))
(setq e (subst nl el e)) ; swap
(entmod e) ; update entity
)
)
(setq n (1+ n)) ; get next entity
)
))
)
; line0.LSP
; Change z coord to zero
;
(defun line0 (/ g n lg e os ns of nf el nl)
(princ "\nChanging LINES: ")
(setq g (ssget "P")) ; get entities
(if g (progn ; check if any
(setq n 0 lg (sslength g)) ; set counter & No of entities
(while (< n lg)
(if (= "LINE" ; check entity type
(cdr (assoc 0 (setq e (entget (ssname g n))))))
(progn ; if OK update
(setq os (assoc 10 e)) ; get current start pt
(setq ns (list(car os)(cadr os)(caddr os) 0.0))
(setq e (subst ns os e)) ; swap
(setq of (assoc 11 e)) ; get current end pt
(setq nf (list(car of)(cadr of)(caddr of) 0.0))
(setq e (subst nf of e)) ; swap
(setq el (assoc 38 e)) ; get current elev
(setq nl (cons 38 0.0))
(setq e (subst nl el e)) ; swap
(entmod e) ; update entity
)
)
(setq n (1+ n)) ; get next entity
)
))
)
; arc0.LSP
; Change z coord to zero
;
(defun arc0 (/ g n lg e os ns el nl)
(princ "\nChanging ARCS: ")
(setq g (ssget "P")) ; get entities
(if g (progn ; check if any
(setq n 0 lg (sslength g)) ; set counter & No of entities
(while (< n lg)
(if (= "ARC" ; check entity type
(cdr (assoc 0 (setq e (entget (ssname g n))))))
(progn ; if OK update
(setq os (assoc 10 e)) ; get current ctr pt
(setq ns (list(car os)(cadr os)(caddr os) 0.0))
(setq e (subst ns os e)) ; swap
(setq el (assoc 38 e)) ; get current elev
(setq nl (cons 38 0.0))
(setq e (subst nl el e)) ; swap
(entmod e) ; update entity
)
)
(setq n (1+ n)) ; get next entity
)
))
)
; sol0.LSP
; Change z coord to zero
;
(defun sol0 (/ g n lg e o1 n1 o2 n2 o3 n3 o4 n4 el nl)
(princ "\nChanging SOLIDS:" )
(setq g (ssget "P")) ; get entities
(if g (progn ; check if any
(setq n 0 lg (sslength g)) ; set counter & No of entities
(while (< n lg)
(if (= "SOLID" ; check entity type
(cdr (assoc 0 (setq e (entget (ssname g n))))))
(progn ; if OK update
(setq o1 (assoc 10 e)) ; get current first pt
(setq n1 (list(car o1)(cadr o1)(caddr o1) 0.0))
(setq e (subst n1 o1 e)) ; swap
(setq o2 (assoc 11 e)) ; get current second pt
(setq n2 (list(car o2)(cadr o2)(caddr o2) 0.0))
(setq e (subst n2 o2 e)) ; swap
(setq o3 (assoc 12 e)) ; get current third pt
(setq n3 (list(car o3)(cadr o3)(caddr o3) 0.0))
(setq e (subst n3 o3 e)) ; swap
(setq o4 (assoc 13 e)) ; get current fourth pt
(setq n4 (list(car o4)(cadr o4)(caddr o4) 0.0))
(setq e (subst n4 o4 e)) ; swap
(setq el (assoc 38 e)) ; get current elev
(setq nl (cons 38 0.0))
(setq e (subst nl el e)) ; swap
(entmod e) ; update entity
)
)
(setq n (1+ n)) ; get next entity
)
))
)
; text0.LSP
; Change z coord to zero
;
(defun text0 (/ g n lg e os ns of nf el nl)
(princ "\nChanging TEXT: ")
(setq g (ssget "P")) ; get entities
(if g (progn ; check if any
(setq n 0 lg (sslength g)) ; set counter & No of entities
(while (< n lg)
(if (= "TEXT" ; check entity type
(cdr (assoc 0 (setq e (entget (ssname g n))))))
(progn ; if OK update
(setq os (assoc 10 e)) ; get current start pt
(setq ns (list(car os)(cadr os)(caddr os) 0.0))
(setq e (subst ns os e)) ; swap
(setq of (assoc 11 e)) ; get current align pt
(setq nf (list(car of)(cadr of)(caddr of) 0.0))
(setq e (subst nf of e)) ; swap
(setq el (assoc 38 e)) ; get current elev
(setq nl (cons 38 0.0))
(setq e (subst nl el e)) ; swap
(entmod e) ; update entity
)
)
(setq n (1+ n)) ; get next entity
)
))
)
; pt0.LSP
; Change z coord to zero
;
(defun pt0 (/ g n lg e os el nl)
(princ "\nChanging POINTS: ")
(setq g (ssget "P")) ; get entities
(if g (progn ; check if any
(setq n 0 lg (sslength g)) ; set counter & No of entities
(while (< n lg)
(if (= "POINT" ; check entity type
(cdr (assoc 0 (setq e (entget (ssname g n))))))
(progn ; if OK update
(setq os (assoc 10 e)) ; get current start pt
(setq ns (list(car os)(cadr os)(caddr os) 0.0))
(setq e (subst ns os e)) ; swap
(setq el (assoc 38 e)) ; get current elev
(setq nl (cons 38 0.0))
(setq e (subst nl el e)) ; swap
(entmod e) ; update entity
)
)
(setq n (1+ n)) ; get next entity
)
))
)
; dim0.LSP
; Change z coord to zero
;
(defun dim0 (/ g n lg e o1 n1 o2 n2 o3 n3 o4 n4 o5 n5 o6 n6 o7 n7 el nl)
(princ "\nChanging DIMS: ")
(setq g (ssget "P")) ; get entities
(if g (progn ; check if any
(setq n 0 lg (sslength g)) ; set counter & No of entities
(while (< n lg)
(if (= "DIMENSION" ; check entity type
(cdr (assoc 0 (setq e (entget (ssname g n))))))
(progn ; if OK update
(setq o1 (assoc 10 e)) ; get current first pt
(setq n1 (list(car o1)(cadr o1)(caddr o1) 0.0))
(setq e (subst n1 o1 e)) ; swap
(setq o2 (assoc 11 e)) ; get current second pt
(setq n2 (list(car o2)(cadr o2)(caddr o2) 0.0))
(setq e (subst n2 o2 e)) ; swap
(setq o3 (assoc 12 e)) ; get current third pt
(setq n3 (list(car o3)(cadr o3)(caddr o3) 0.0))
(setq e (subst n3 o3 e)) ; swap
(setq o4 (assoc 13 e)) ; get current fourth pt
(setq n4 (list(car o4)(cadr o4)(caddr o4) 0.0))
(setq e (subst n4 o4 e)) ; swap
(setq o5 (assoc 14 e)) ; get current fifth pt
(setq n5 (list(car o5)(cadr o5)(caddr o5) 0.0))
(setq e (subst n5 o5 e)) ; swap
(setq o6 (assoc 15 e)) ; get current sixth pt
(setq n6 (list(car o6)(cadr o6)(caddr o6) 0.0))
(setq e (subst n6 o6 e)) ; swap
(setq o7 (assoc 16 e)) ; get current seventh pt
(setq n7 (list(car o7)(cadr o7)(caddr o7) 0.0))
(setq e (subst n7 o7 e)) ; swap
(setq el (assoc 38 e)) ; get current elev
(setq nl (cons 38 0.0))
(setq e (subst nl el e)) ; swap
(entmod e) ; update entity
)
)
(setq n (1+ n)) ; get next entity
)
))
)
; pline0.LSP
; Change z coord to zero
;
(defun pline0 (/ g n lg e os ns el nl ed en)
(princ "\nChanging PLINES and DONUTS: ")
(setq g (ssget "P")) ; get entities
(if g (progn ; check if any
(setq n 0 lg (sslength g)) ; set counter & No of entities
(while (< n lg)
(if (= "POLYLINE" ; check entity type
(cdr (assoc 0 (setq e (entget (ssname g n))))))
(progn ; if OK update
(setq os (assoc 10 e)) ; get current start pt
(setq ns (list(car os)(cadr os)(caddr os) 0.0))
(setq e (subst ns os e)) ; swap
(setq el (assoc 38 e)) ; get current elev
(setq nl (cons 38 0.0))
(setq e (subst nl el e)) ; swap
(entmod e) ; modify entity
;
; SUBENTS
(SETQ en (DXF -1 e)) ;get first subentity - vertex
(while (and (setq en (entnext en));loop thu each vertex
(SETQ ED (ENTGET EN));get vertex data
(/= "SEQEND" (dxf 0 ed)); if seqend finish
);and
(progn
(setq os (assoc 10 ed)) ; get current vertex pt
(setq ns (list(car os)(cadr os)(caddr os) 0.0));build new pt
(setq ed (subst ns os ed)) ; swap
(setq el (assoc 38 e)) ; get current elev
(setq nl (cons 38 0.0))
(setq e (subst nl el e)) ; swap
(entmod ed);modify the vertex
);progn
);while
(entupd en)
)
);if
(setq n (1+ n)) ; get next entity
)
))
)
; ins0.LSP
; Change z coord to zero
;
(defun ins0 (/ g n lg e os ns el nl)
(princ "\nChanging BLOCK INSERTS: ")
(setq g (ssget "P")) ; get entities
(if g (progn ; check if any
(setq n 0 lg (sslength g)) ; set counter & No of entities
(while (< n lg)
(if (= "INSERT" ; check entity type
(cdr (assoc 0 (setq e (entget (ssname g n))))))
(progn ; if OK update
(setq os (assoc 10 e)) ; get current ctr pt
(setq ns (list(car os)(cadr os)(caddr os) 0.0))
(setq e (subst ns os e)) ; swap
(setq el (assoc 38 e)) ; get current elev
(setq nl (cons 38 0.0))
(setq e (subst nl el e)) ; swap
(entmod e) ; update entity
)
)
(setq n (1+ n)) ; get next entity
)
))
)
;
(defun c:zero ()
(setq g (ssget)) ; get entities
(circ0)
(line0)
(arc0)
(sol0)
(text0)
(pt0)
(dim0)
(pline0)
(ins0)
(princ)
)